<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePayinfoTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payinfo', function (Blueprint $table) {
            $table->increments('id');

            $table->string('shop_id', 20)->default('')->comment('商户ID');
            $table->string('user_id', 20)->default('')->comment('用户ID');

            $table->string('order_num')->default('')->comment('订单号');
            $table->integer('amount')->default(0)->comment('实付金额');
            $table->enum('payment', ['wechat', 'alipay', 'ttg'])->default('wechat')->comment('支付方式');
            $table->string('callback')->default(0)->comment('回调地址');
            $table->json('other')->default('')->comment('其他');
            $table->enum('status', ['fail', 'success'])->default('fail')->comment('状态');
            $table->integer('create_time')->default(0)->comment('创建时间');
            $table->integer('update_time')->default(0)->comment('更新时间');

            // 索引
            $table->index('shop_id');
            $table->index('user_id');
            $table->index('order_num');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('payinfo');
    }
}
